
#ifndef etl_variant_h
#define etl_variant_h

#include <string.h>

#include "etl_string.h"

namespace etl
{

class etl_variant
{  
  union etl_numeric_box
  {
    long s32;
    unsigned long u32;
    double d64;  
  };

 public:

  enum etl_variant_type
    {
      EMPTY,
      SIGNED_INTEGER,
      UNSIGNED_INTEGER,
      FLOATING_POINT,
      BYTES,
      TEXT
    };

  etl_variant();

  etl_variant( const etl_variant& obj );

  virtual ~etl_variant();

  etl_variant& operator = ( const etl_variant& obj );

  etl_variant_type get_type();

  int set_signed_integer( long val );
  int set_unsigned_integer( unsigned long val );
  int set_floating_point( double val );
  int set_bytes( const unsigned char* data, unsigned long size );
  int set_string( etl_string val );

  int get_signed_integer( long& val );
  int get_unsigned_integer( unsigned long& val );
  int get_floating_point( double& val );
  int get_bytes( unsigned char** data, unsigned long& size );
  int get_string( etl_string& val );

  int clear();

 private:

  etl_variant& copy( const etl_variant& obj );

  etl_variant_type type;

  union etl_numeric_box numerics;
  unsigned char* bytes;
  unsigned long bytesSize;
  etl_string text;

};

}

#endif
